/*
 *  TravelTest.cpp
 *  SpaceTrader
 *
 *  Created by Jake on 11/20/12.
 *  Copyright 2012 The Hex Pistols. All rights reserved.
 *
 */

#include "TravelTest.h"

CPPUNIT_TEST_SUITE_REGISTRATION(TravelTest);


void TravelTest::setUp()
{
	player = new Player();
	market = new Market();
	universe = new Universe(market);
	travelManager = new TravelManager();
}

void TravelTest::reset()
{
	player->getShip()->setFuel(0);
}

void TravelTest::tearDown()
{
	delete universe;
	delete travelManager;
}

void TravelTest::testDistanceSameSystem()
{
	reset();

    A = universe->getSystems()[0]->getPlanets()[0];
	B = universe->getSystems()[0]->getPlanets()[1];
	
    int res = travelManager->getDistance(A,B,universe);
    CPPUNIT_ASSERT(res == 31);
	int oldFuel = player->getFuel();
	player->travel(res);
	CPPUNIT_ASSERT(player->getFuel() == oldFuel-res);
}

void TravelTest::testDistanceDiffSystem() 
{
	reset();

    A = universe->getSystems()[0]->getPlanets()[0];
	B = universe->getSystems()[1]->getPlanets()[1];
	
    int res = travelManager->getDistance(A,B,universe);
    CPPUNIT_ASSERT(res == 173);
	int oldFuel = player->getFuel();
	player->travel(res);
	CPPUNIT_ASSERT(player->getFuel() == oldFuel-res);
}

void TravelTest::testOutOfRange() 
{
	reset();

	A = universe->getSystems()[0]->getPlanets()[0];
	B = universe->getSystems()[2]->getPlanets()[1];
    int res = travelManager->getDistance(A,B,universe);
    CPPUNIT_ASSERT(res == 320);
	int oldFuel = player->getFuel();
	player->travel(res);
	CPPUNIT_ASSERT(player->getFuel() == oldFuel-res);
}

